<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .parent {
      position: relative;
      /* display: flex;
      justify-content: center;
      align-items: center; */
      width: 500px;
      height: 500px;
      background-color: skyblue;
    }

    .son {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%,-50%);
      width: 200px;
      height: 200px;
      background-color: purple;
    }
  </style>


</head>

<body>

  <div id="box">
    {{text}}
    <div class="parent" @click="parent">
      父级
      <!--@click.stop 阻止冒泡-->
      <div class="son" @click="son">
        儿子
        <!--@click.prevent.stop连写,可以阻止默认行为和冒泡-->
        <a @click.prevent.stop href="https://www.baidu.com/">点击跳转</a>
      </div>
    </div>
    <br>

    <!--@click.prevent阻止跳转===默认行为-->
    <a @click.prevent href="https://www.baidu.com/">点击跳转</a>
  </div>

  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
  <script>


    new Vue({
      el: '#box',
      data: {
        text: ''
      },
      methods: {
        parent() {
          console.log('parent');
        },
        son() {
          console.log('son');
        }
      }
    })

  </script>

</body>

</html>